import { Component, PropsWithChildren } from 'react'
import { Provider } from 'mobx-react'
import Taro from '@tarojs/taro'

import counterStore from './store/counter'
import 'taro-ui/dist/style/index.scss'
import './app.scss'

const store = {
    counterStore
}

class App extends Component<PropsWithChildren> {
    componentDidMount() {
        const WeappEnv = Taro.getEnv() === Taro.ENV_TYPE.WEAPP
        if (WeappEnv) {
            Taro.cloud.init(
                {
                    env: 'test1-7ghkuw85613044d6',  // 云开发环境ID
                    traceUser: true,
                }
            )
        }
    }

    componentDidShow() { }

    componentDidHide() { }

    // this.props.children 就是要渲染的页面
    render() {
        return (
            <Provider store={store}>
                {this.props.children}
            </Provider>
        )
    }
}

export default App
